home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / DOCZ16.ZIP;1 / DOCZ.LIF / INSERT.MAR < prev    next >
Encoding:
Text File  |  1994-04-24  |  2.1 KB  |  66 lines

  1.     .IF DEFINED DOCUMENTATION
  2. ; ***************************************************************************
  3. .MODULE        insert
  4. .LIBRARY       csub
  5. .TYPE           function
  6. .APPLICATION       string
  7. .SYSTEM        msdos-s
  8. .SYSTEM        msdos-l
  9. .SYSTEM        vms
  10. .SYSTEM        unix
  11. .AUTHOR        Software Toolz
  12. .LANGUAGE       VAX-11 Assembly
  13. .DESCRIPTION
  14.    Insertion of one string into another
  15. .ARGUMENTS
  16.    char *insert(pattern,str,pos)
  17.       char  *pattern,          /* (r) the characters to insert */
  18.         *str;          /* (r/w) the destination string */
  19.       int   pos;          /* (r) the position at which to insert */
  20. .NARRATIVE
  21.    Insert the "pattern" string into the destination string, "str", beginning
  22.    at position, "pos", in the destination string.
  23. .RETURNS
  24.    A pointer to your destination string.
  25. .REVISIONS       1/28/87
  26.    Return pointer to destination string (rewritten in Assembly).
  27. .EXAMPLE
  28.    char buff[128];
  29.    strcpy(buff,"this test");
  30.    insert("is a ",buff,5);
  31. .NOTICE
  32.    Copyright 1989 Software Toolz, Inc. - Atlanta, Georgia
  33.  
  34.    All rights reserved worldwide.  This program may not be reproduced,
  35.    transmitted, transcribed, stored in a retrieval system or translated in
  36.    any human or computer language, in any form without the express written
  37.    permission of Software Toolz, Inc.
  38. .ENDOC           END DOCUMENTATION
  39. ; ***************************************************************************
  40.     .ENDC                ; DOCUMENTATION
  41.  
  42.     .TITLE    INSERT
  43.                     ; share a CODE PSECT with C functions
  44.  
  45.     .PSECT    $CODE,PIC,USR,CON,REL,LCL,SHR,EXE,RD,NOWRT,NOVEC
  46.  
  47.     .ENTRY INSERT,^M<R2,R3,R4,R5>
  48.  
  49.     ADDL3    8(AP),12(AP),R2     ; calculate address of break
  50.     PUSHL    R2
  51.     CALLS    #1,G^STRLEN        ; calculate length hi-part of string
  52.     MOVL    R0,R3            ; copy value for save
  53.     INCL    R3            ; add space for NULL
  54.     PUSHL    4(AP)            ; get pattern string length
  55.     CALLS    #1,G^STRLEN
  56.     ADDL3    R0,R2,R4
  57.     PUSHR    #^M<R0,R2>
  58.     MOVC3    R3,(R2),(R4)        ; move hi-part up
  59.     POPR    #^M<R0,R2>
  60.     MOVC3    R0,@4(AP),(R2)        ; copy in the pattern string
  61.     MOVL    8(AP),R0        ; copy string address for return
  62.  
  63.     RET
  64.  
  65.     .END                ; stop assembly here
  66.